# a = 'Hello World, Hello    Python'
a = input('请输入英文内容:').lower()
# 去除语句中可能出现的标点符号
a = a.replace(',', '')
a = a.replace('.', '')
a = a.replace('，', '')
a = a.replace('。', '')
a = a.replace('!', '')
a = a.replace('?', '')
# 使用空格来分割字符串
# ['Hello', 'World', 'Hello', '', '', '', 'Python']
all_words = a.split(' ')  # 可能包含多余的空格

# {'Hello', 'World', 'Python', ''}
words = set(all_words)  # 转换成集合，去重
# {'Hello', 'World', 'Python'}
words.remove('')

word_count = {}  # 空字典
# print(all_words.count('Hello'))  # 计算目标在列表中出现的次数
for temp in words:  # 3个单词
    # 根据all_words列表来判断出现次数
    # word_count.update(temp=all_words.count(temp)) # 不对
    # word_count[temp] = all_words.count(temp)
    word_count.update({temp: all_words.count(temp)})
print(word_count)
